<template>
	<div>
		<van-empty description="" v-if="finished&&list.length==0">
		  <template #image>
			 <van-icon size="180" color="#999" name="search" />
		  </template>
		</van-empty>
		<van-list v-model="loading" :finished="finished" @load="get_list" :finished-text="finishedText"  >
			
			<slot name="content" :list="list"></slot>
		</van-list>
	</div>
</template>

<script>
	
	export default{
		
		
		data() {
			return {
				limit:10,
				list:[],
				loading:false,//评论列表加载
				finished:false,//评论列表是否记载完毕
				finishedText:'没有更多数据了'
			}
		},
		props:{
			url:{
				required:true,
				type:String
			}
		},
		methods:{
			get_list(Refresh){
				let {article_id,limit,user_id,list,url} =this;
				let skip = list.length;
				if(Refresh){
					skip=0
				}
				
				console.log(this.$attrs);//这个是props
				this.$http.post(url,{
					limit,
					skip,
					...this.$attrs
				}).then(res=>{
					
					console.log(res)
					if(res.code==0){
						if (Refresh) {
							this.list = [];
							this.$emit('stopRefresh')
						}
						
						
						 this.list.push(...res.data);
						 if(this.list.length>=res.count){
							 this.finished =true;
							 if(res.count===0){
								 
								 this.finishedText = '还没有评论的';
							 }else{
								 this.finishedText='加载完毕~~~';
							 }
						 }else{
							 this.loading =false
						 }
					}
				})
			},
		}
	}
</script>

<style>
</style>
